package operations;

import book.Book;
import book.BookList;

import java.util.Scanner;


/**
 * Created with IntelliJ IDEA
 * Description:增加图书
 * User:22954
 * Date:2024-01-12
 * Time:20:35
 */
public class AddOperation implements IOperation {
    @Override
    public void work(BookList bookList) {
//        System.out.println("增加图书");
        Scanner scanner = new Scanner(System.in);
        System.out.print("Please enter the name of book:");
        String name = scanner.nextLine();
        System.out.print("Please enter the author name of book:");
        String author = scanner.nextLine();
        System.out.print("Please enter the price of book:");
        int price = scanner.nextInt();
        scanner.nextLine();//删除nextInt留下的enter及"\n"
        System.out.print("Please enter the type of book:");
        String type = scanner.nextLine();
        bookList.getBooks().add(new Book(name, author, price, type));
        System.out.println("Successfully Added!");
    }
}
